<tr class="draggable-taxonomy" data-taxonomy-id="<%= taxonomy.id %>" role="row">
  <td role="cell" class="w-12 js-drag-handle"><%== icon("draggable", class: "dragger") %></td>
  <td role="cell">
    <ul class="taxonomy">
      <% if taxonomy.root? %>
        <li>
          <span class="md:hidden"><%= t("decidim.admin.taxonomies.name") %>: </span>
          <%= link_to translated_attribute(taxonomy.name), edit_taxonomy_path(taxonomy), class: "js-drawer-editor" %>
        </li>
        <li>
          <span class="md:hidden"><%= t("decidim.admin.taxonomies.total_items") %>: </span>
          <%= taxonomy.all_children.count %>
        </li>
        <li>
          <span class="md:hidden"><%= t("decidim.admin.taxonomies.total_filters") %>: </span>
          <%= taxonomy.filters_count %>
        </li>
      <% else %>
        <li>
          <span class="md:hidden"><%= t("decidim.admin.taxonomies.name") %>: </span>
          <%= link_to translated_attribute(taxonomy.name), edit_taxonomy_item_path(taxonomy_id: taxonomy.root_taxonomy.id, id: taxonomy.id), class: "js-drawer-editor" %>
        </li>
        <li>
          <span class="md:hidden"><%= t("decidim.admin.taxonomies.count") %>: </span>
          <%= taxonomy.taxonomizations_count %>
        </li>
      <% end %>

      <li class="taxonomy-list__actions">
        <span class="md:hidden !ml-0"><%= t("decidim.admin.taxonomies.actions.actions") %>: </span>
        <%= render "taxonomy_actions", taxonomy: %>
      </li>
    </ul>
    <% if with_children && taxonomy.children.any? %>
      <div class="js-sortable js-draggable-<%= taxonomy.id %>"
           data-draggable-handle=".js-drag-handle"
           data-draggable-accept-from=".js-draggable-<%= taxonomy.id %>"
           data-sort-url="<%= reorder_taxonomies_path %>"
           data-parent-id="<%= taxonomy.id %>">
        <% taxonomy.children.each do |child| %>
          <%= render partial: "decidim/admin/taxonomies/row_children", locals: { child:, class_name: "", grandchild: false } %>

          <% if child.children.any? %>
            <div class="js-sortable js-draggable-<%= child.id %>"
                 data-draggable-handle=".js-drag-handle"
                 data-draggable-accept-from=".js-draggable-<%= child.id %>"
                 data-sort-url="<%= reorder_taxonomies_path %>"
                 data-parent-id="<%= child.id %>">
              <% child.children.each do |grandchild| %>
                <%= render partial: "decidim/admin/taxonomies/row_children", locals: { child: grandchild, class_name: "ml-6", grandchild: true } %>
              <% end %>
            </div>
          <% end %>
        <% end %>
      </div>
    <% end %>
  </td>
</tr>
